package Admin.servlet;

import Admin.entity.Admin;
import Admin.service.AdminService;
import Admin.service.impl.AdminServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author chenle
 * @version 1.0
 * @date 2023/9/22 17:09
 */
@WebServlet("/AdminDelServlet")
public class AdminDelServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        String idStr=request.getParameter("id");
        int id=idStr!=null?Integer.parseInt(idStr):0;

        AdminService service=new AdminServiceImpl();

        Admin admin=new Admin();
        admin.setId(id);
        int count=service.delete(admin);

        PrintWriter out=response.getWriter();
        out.print(count);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
